namespace EyeOpen.Trial.Mvc
{
	using System;
	using System.Collections.Generic;
	using System.Web.Mvc;

	using EyeOpen.Trial.Data;

	public class ApplicationResolver 
		: IDependencyResolver
	{
		public object GetService(Type serviceType)
		{
			if (serviceType == typeof(IApplicationUnitOfWork))
			{
				var context = new ApplicationUnitOfWorkEf("System.Data.SqlServerCe.4.0", "Data Source=|DataDirectory|Application.sdf");

				if (!context.Database.Exists())
				{
					context.Database.Create();
					new DbPopulator(context)
						.Populate();
				}

				return
					context;
			}

			return null;
		}

		public IEnumerable<object> GetServices(Type serviceType)
		{
			return
				new List<object>();
		}
	}
}